package operation;

import book.BookList;

import java.util.Scanner;

public class BoorowOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("借阅图书");
        System.out.print("请问您借阅那本书:");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            if(bookList.getBook(i).getName().equals(name)){
                if(bookList.getBook(i).isBorrowed() == false){
                    bookList.getBook(i).setBorrowed(true);
                    return;
                }else {
                    System.out.println("您想借阅的书已经被借走了");
                    return;
                }
            }
        }
        System.out.println("本书库没有此书");
    }
}
